home *** CD-ROM | disk | FTP | other *** search
- /*
- * ADDGGROUPFRAME.C
- */
-
- #include "newlook.h"
-
- extern void CopyMem(APTR,APTR,ULONG);
- extern LONG IntuiTextLength(struct IntuiText *);
-
- BOOL AddGGroupFrame(g, dx,dy, w,h, title)
- struct Gadget *g;
- SHORT dx,dy, w,h;
- STRPTR title;
- {
- struct TextFont *tf;
- struct IntuiText *it;
- struct Border *b0, *b1;
- SHORT *xy, tx= dx, ty= dy, cw;
-
- ULONG UserHandle= SetNewLookHandle(PRIVATE_HANDLE);
-
- /* No Border for Gadgets w/ Images */
- if(g && (g->Flags & GADGIMAGE) == NULL)
- {
- if(tf= (struct TextFont *)OpenFont(&Topaz80))
- {
- ty -= tf->tf_Baseline / 2;
- tx += 3 * (cw = tf->tf_XSize);
- CloseFont(tf);
- }
- else ty -= 3, tx += 3 * (cw = 8); /* `known' topaz 80 dimensions */
-
- if(it= CreateIText(tx,ty,title))
- {
- if(b0= (struct Border *)SmartAllocate(BORDERSIZE))
- {
- if(b1= (struct Border *)SmartAllocate(BORDERSIZE))
- {
- if(xy= (SHORT *)SmartAllocate(GFRAMEXYSIZE))
- {
- --w;
- --h;
-
- xy[0]= 2*cw; xy[1]= 0; /* +-+ title +-----------+ */
- xy[2]= 0; xy[3]= 0; /* | | */
- xy[4]= 0; xy[5]= h; /* | | */
- xy[6]= w; xy[7]= h; /* | | */
- xy[8]= w; xy[9]= 0; /* +---------------------+ */
-
- xy[10]= 4*cw + IntuiTextLength(it);
- xy[11]= 0;
-
- b0->LeftEdge = dx;
- b0->TopEdge = dy;
- b0->FrontPen = 1L;
- b0->BackPen = 0L;
- b0->DrawMode = JAM1;
- b0->Count = 6;
- b0->XY = &xy[0];
- b0->NextBorder = (struct Border *)NULL;
-
- CopyMem((APTR)b0, (APTR)b1, BORDERSIZE);
-
- b0->NextBorder= g->GadgetRender;
- g->GadgetRender= b0;
-
- b1->NextBorder= g->SelectRender;
- g->SelectRender= b1;
-
- it->NextText= g->GadgetText;
- g->GadgetText= it;
-
- MakePrivateHandlePublic(UserHandle);
- return TRUE;
- }
- }
- }
- }
- }
-
- if(UserHandle != PRIVATE_HANDLE)
- {
- SmartFreeAll(PRIVATE_HANDLE);
- (void)SetNewLookHandle(UserHandle);
- }
- return FALSE;
- }
-